package com.sqlcheck.enums;

/**
 * Git平台枚举
 */
public enum GitPlatform {
    GITLAB("GitLab", "https://gitlab.com"),
    GITEE("Gitee", "https://gitee.com"),
    GITHUB("GitHub", "https://github.com");
    
    private final String displayName;
    private final String defaultServerUrl;
    
    GitPlatform(String displayName, String defaultServerUrl) {
        this.displayName = displayName;
        this.defaultServerUrl = defaultServerUrl;
    }
    
    public String getDisplayName() {
        return displayName;
    }
    
    public String getDefaultServerUrl() {
        return defaultServerUrl;
    }
    
    /**
     * 根据服务器URL判断Git平台类型
     */
    public static GitPlatform fromServerUrl(String serverUrl) {
        if (serverUrl == null) {
            return GITLAB;
        }
        
        String lowerUrl = serverUrl.toLowerCase();
        if (lowerUrl.contains("gitee.com")) {
            return GITEE;
        } else if (lowerUrl.contains("github.com")) {
            return GITHUB;
        } else {
            return GITLAB;
        }
    }
}